#ifndef _MCMC_SYMPHONY
#define _MCMC_SYMPHONY

#include "mcmcRegionDynamics.h"
#include "mcmcSW.h"
#include "mcmcFaceModel.h"

#define NUM_DYNAMIC 2




///////////////////////////////////////////////
// class of the conductor
class MCMC_Conductor
{
public:
	// construction & destruction
	MCMC_Conductor(MCMC_Map_2Layers &map, mcmcMatrix<int> partition_maps1[3], int num[],Raster_Color<uchar> &raster,
				   mcmcMatrix<int> &mx_init_clst, const MCMC_SegSetting& setting, char *pfile_name=NULL);
	~MCMC_Conductor();

	// operations
	bool			OneStep(void);
	void			Go(char *fname, const MCMC_SegSetting *psetting=NULL);
	double			UpdateEnergy(const int nEnergy=0);
	void			SaveEnergy(char *file);

	inline			MCMC_Layer_Regions	*LayerRegion(void);
	void			ChangeAllGraphPointers(MCMC_Map_2Layers &map);
	double			TotalDist(mcmcMatrix<int> &mx_gN, mcmcMatrix<int> &mx_gK);
	inline bool		IsColorImage(void){return bcolor;};
	virtual void	SetScaleFactor(const double sc);

	// new procedures
	void			GoNew(char *fname, const MCMC_SegSetting &setting);
	void			OneStepNew(void);
	
	void			ReCreateTopology(void);

protected:
	void			SetModelPointers(void);

public:
	MCMC_SW_Cuts_2Way	sw_coordinator;

	MCMC_Map_2Layers	*pmap;					// active map
	MCMC_Map_2Layers	*pmap_buf;				// buffer that saves the old map
	mcmcMatrix<int>			*partition_maps[3];
	MCMC_FilterResp		respFilter;
	int					step;
	char				Info[4][200];
	mcmcVector<double>		vc_energy_total;
	MCMC_Particle		*pmcmc_particle_gauss;

protected:
	MCMC_Diffusion		mcmc_diffusion;
	MCMC_ModelSupervisor model_supervisor;

	CFaceDetector		face_dector;
	MCMC_FaceParticles	face_particles;

private:
	MCMC_Dynamic		*dynamics[NUM_DYNAMIC];
	MCMC_Dn_RepartitionARegions		*pdn_change_underling;
	RF_uniform			rf_dynamics;
	RF_uniform			rf_dynamics_new;
	int					dn;
	bool				bcolor;
};

inline MCMC_Layer_Regions* MCMC_Conductor::LayerRegion(void)
{
	if (pmap == NULL)
		return NULL;
	else
		return pmap->LayerRegion();
}


#endif
